////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRay_FireStaticTurret extends BailterRay_FireTurret
                     placeable;

var float ElapsedTimeSincePause;
var bool bWaitingToFire;

const FIRE_TIME                = 5.0;
const FIRE_PAUSE_TIME         = 2.0;

simulated function Tick(float DeltaTime)
{
    local vector FireLoc;
    local rotator FireRot;

    ElapsedTimeSinceFiring += DeltaTime;
    ElapsedTimeSincePause += DeltaTime;

    // Get location and direction of turret head
    WeaponComponent.GetSocketWorldLocationAndRotation(FiringSocket, FireLoc, FireRot);
    HeadCollision.SetTranslation(vector(WeaponComponent.Rotation) * 22);

    if(ElapsedTimeSincePause < FIRE_TIME)
    {
        if(ElapsedTimeSinceFiring >= FireTurret.FireInterval)
        {
            Firing(FireLoc, FireRot);
            ElapsedTimeSinceFiring = 0;
        }
    }
    if(ElapsedTimeSincePause >= FIRE_TIME)
    {
        if(!bWaitingToFire)
        {
            bWaitingToFire = true;
            setTimer(FIRE_PAUSE_TIME, false, 'RestartFiring');
        }
    }
}

function RestartFiring()
{
    bWaitingToFire = false;
    ElapsedTimeSincePause = 0;
}

defaultproperties
{
     bWaitingToFire = false
     ElapsedTimeSincePause = 0
}